/**
 * Created with IntelliJ IDEA.
 * Description: leetcode.中等题.除自身以外数组的乘积
 */

class Solution {
    public int[] productExceptSelf(int[] nums) {
        int[] left = new int[nums.length];
        left[0] = 1;
        int right = 1;
        int[] ret = new int[nums.length];
        for(int i = 1; i < nums.length; i++) {
            left[i] = left[i - 1] * nums[i - 1];
        }
        for(int i = nums.length - 1; i >= 0; i--){
            ret[i] = left[i] * right;
            right *= nums[i];
        }
        return ret;
    }
}

public class Test {
}
